<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="app" uri="http://www.wanrenhui.com" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
	  <%@include file="/res/include/base-head.jsp"%>
	  <%@include file="/res/include/jquery-easyui.jsp"%>
	<script type="text/javascript" src="${pageContext.request.contextPath}/res/js/ad/adBase.js"></script>
  </head>
  <body>
  <div id="toolbar" style="padding:2px;">
    <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="admin.adBase.toAdd();">添加</a>
    <script type="text/javascript" src="${pageContext.request.contextPath}/res/js/area.js"></script>
</div>
	<div class="easyui-layout" data-options="fit:true">
		<div data-options="region:'north',border:false,split:false">
		 	<form id="query-form" class="search_form clearfix">
		            <dl>
					<dt>省：</dt>
					 <dd>
	                	<select name="provinceId" id="provinceId" onchange="admin.area.changeProvince()" class="txt grid-8">
	                		<c:forEach var="province" items="${provinceList}">  
                                <option value="${province.id}">${province.name}</option>  
                            </c:forEach>
	                	</select>
	                </dd>
				</dl>
				<dl>
					<dt>市：</dt>
					 <dd>
	                	<select name="cityId" id="cityId" onchange="admin.area.changeCity()" class="txt grid-8">
	                		<option value="">--请选择--</option>
	                	</select>
	                </dd>
				</dl>
				<dl>
					<dt>区：</dt>
					 <dd>
	                	<select name="areaId" id="areaId" onchange="admin.area.changeArea()" class="txt grid-8">
	                		<option value="">--请选择--</option>
	                	</select>
	                </dd>
				</dl>
				<dl>
					<dt>社区：</dt>
					<dd>
						<select name="communityId" id="communityId" class="txt grid-8">
	                		<option value="">--请选择--</option>
	                	</select>
					</dd>
				</dl>
		            <dl>    
		                <dt>类型：</dt>
		                <dd>
		                	<select name="type" id="type">
		                		<option value="">请选择</option>
		                		<c:forEach items="${typeList}" var="item">
		                			<option value="${item.code}">${item.name}</option>
		                		</c:forEach>
		                	</select>
		                </dd>
		            </dl>
		            <p class="search_form_btn">
		            	<input type="button" value="搜索" class="icon_serach" onclick="admin.adBase.query()" />
		            </p>
		        </form>
		   </div>
	    <div data-options="region:'center',border:false">
		    <table id="datagrid" data-options="url:'${pageContext.request.contextPath}/ad/base/list',toolbar:'#toolbar'">
				<thead>
					<tr>
						<th data-options="field:'img',width:120,formatter:formatImg">广告图片</th>
						<th data-options="field:'title',width:120,align:'center'">标题</th>
						<th data-options="field:'typeStr',width:100,align:'center'">类型</th>
						<th data-options="field:'communityName',width:80,align:'center'">所属社区</th>
						<th data-options="field:'titleImg',width:120,align:'center',formatter:formatTitleImg">标题图片</th>
						<th data-options="field:'content',width:150,align:'center' ">内容</th>
						<th data-options="field:'oidx',width:50,align:'center' ">排序</th>
						<th data-options="field:'contentImg',width:200,align:'center',formatter:formatImgs ">内容图片</th>
						<th data-options="field:'href',width:120,align:'center'">连接地址</th>
						<th data-options="field:'jsonData',width:120,align:'center'">UI参数</th>
						<th data-options="field:'path',width:120,align:'center'">UI路径</th>
			            <th data-options="field:'id',align:'center',width:150,formatter:formatOperation">管理操作</th>
					</tr>
				</thead>
			</table>
	  	</div>
	</div>
	<script>
		function formatImg(img){
	        return '<img style="width:120px;height:120px;" src="http://file.xfquanquan.com'+img+'"/>'
	    }
		function formatTitleImg(titleImg){
			var l_html = '';
			if(null!=titleImg&&''!=titleImg){
				l_html='<img style="width:120px;height:120px;" src="http://file.xfquanquan.com'+titleImg+'"/>'
			}
	        return l_html
	    }
		function formatImgs(contentImg){
			var l_html = '';
			if(null!=contentImg&&''!=contentImg){
				var imgs=contentImg.split(";");
				if(imgs.length>0){
					for(var i=0;i<imgs.length;i++){
						l_html+='<img style="width:120px;height:120px;" src="http://file.xfquanquan.com'+imgs[i]+'"/>'
					}
				}
			}
	        return l_html
	    }
		function formatOperation(value,row,index) {
			var l_html = '';
			l_html += '<a href="javascript:;" class="table_link" onclick="admin.adBase.toExpireAt('+row.id+')">失效</a>';
			l_html += '<a href="javascript:;" class="table_link" onclick="admin.adBase.toUpdate('+row.id+')">编辑</a>';
			return l_html;
		}
	</script>
  </body>
</html>
